package client.graphics 
{
	import com.greensock.TweenMax;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * GRSeekbar
	 * @version ActionScript 3.0
	 * @author Adrian C. Miranda
	 * @mail ad@adrianmiranda.com.br
	 */
	public class GRSeekbar extends Sprite
	{
		private static const RADIUS:Number = 0;
		public var background:Shape = addChild(new Shape()) as Shape;
		public var buffer:Shape = addChild(new Shape()) as Shape;
		public var seek:Shape = addChild(new Shape()) as Shape;
		public var hit:Sprite = addChild(new Sprite()) as Sprite;
		
		public function GRSeekbar() 
		{
			super();
			draw();
		}
		
		private function draw():void
		{
			addEventListener(MouseEvent.MOUSE_OVER, onSeekOver);
			addEventListener(MouseEvent.MOUSE_OUT, onSeekOut);
			with (background)
			{
				graphics.clear();
				graphics.beginFill(0x444444, 0.4);
				graphics.drawRoundRectComplex(0, 6, 400, 3, RADIUS, RADIUS, RADIUS, RADIUS);
				graphics.endFill();
			}
			with (buffer)
			{
				graphics.clear();
				graphics.beginFill(0x00CCFF, 0.6);
				graphics.drawRoundRectComplex(0, 6, 400, 3, RADIUS, RADIUS, RADIUS, RADIUS);
				graphics.endFill();
				mask = hit;
				width = 0;
			}
			with (seek)
			{
				graphics.clear();
				graphics.beginFill(0x00CCFF, 1);
				graphics.drawRoundRectComplex(0, 6, 400, 3, RADIUS, RADIUS, RADIUS, RADIUS);
				graphics.endFill();
				mask = hit;
				width = 0;
			}
			with (hit)
			{
				graphics.clear();
				graphics.beginFill(0x00FFFF, 0.8);
				graphics.drawRoundRectComplex(0, 0, 400, 15, RADIUS, RADIUS, RADIUS, RADIUS);
				graphics.endFill();
				width = 0;
			}
		}
		
		private function onSeekOver(evt:MouseEvent):void 
		{
			TweenMax.to(background, 0.6, { alpha:0.3, glowFilter: { color:0x000000, alpha:0.4, blurX:4, blurY:4 }} );
			TweenMax.to(buffer, 0.6, { alpha:0.9, glowFilter: { color:0x00CCFF, alpha:0.4, blurX:5, blurY:5 }} );
			TweenMax.to(seek, 0.6, { glowFilter: { color:0x00CCFF, alpha:0.4, blurX:4, blurY:4 }} );
		}
		
		private function onSeekOut(evt:MouseEvent):void 
		{
			TweenMax.to(background, 0.6, { alpha:0.4, glowFilter: { color:null, alpha:0, blurX:0, blurY:0 }} );
			TweenMax.to(buffer, 0.6, { alpha:0.6, glowFilter: { color:null, alpha:0, blurX:0, blurY:0 } } );
			TweenMax.to(seek, 0.6, { glowFilter: { color:null, alpha:0, blurX:10, blurY:10 }} );
		}
		
	}

}